Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support async bulk api #90

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

RainJayTsai
Copy link

feature async bulk api

@codecov
Copy link

codecov bot commented Apr 1, 2018

Codecov Report

Merging #90 into master will increase coverage by 0.2%.
The diff coverage is 98.79%.

Impacted file tree graph

@@           Coverage Diff            @@
##           master     #90     +/-   ##
========================================
+ Coverage    97.5%   97.7%   +0.2%     
========================================
  Files           7       7             
  Lines         440     522     +82     
  Branches       78      94     +16     
========================================
+ Hits          429     510     +81     
  Misses          7       7             
- Partials        4       5      +1
Impacted Files Coverage Δ
aioelasticsearch/helpers.py 98.78% <98.79%> (-0.01%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a05cab3...2b561e7. Read the comment docs.

@hellysmile
Copy link
Member

Thanks for the contribution! Can You add some tests?

@hellysmile
Copy link
Member

This project still support Python 3.5.3-, can You pass everywhere explicit loop?

@@ -147,3 +150,121 @@ def _update_state(self, resp):
self._successful_shards = resp['_shards']['successful']
self._total_shards = resp['_shards']['total']
self._done = not self._hits or self._scroll_id is None


async def worker_bulk(client, datas: List[dict], actions: List[str], **kwargs):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All project do not provide yet typings everywhere, so it not makes to put them here. Later typings will be provided everywhere...

Copy link
Member

@hellysmile hellysmile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can You make travis green?

async def _retry_handler(client, futures, max_retries, initial_backoff,
max_backoff, **kwargs):
finish = 0
for attempt in range(max_retries + 1):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have You copied this implementation from original library?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sleep = min(max_backoff, initial_backoff * 2 ** (attempt - 1))
await asyncio.sleep(sleep)

results = await asyncio.gather(*futures,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gather produces unexpected load, not sure, but maybe it should be rewritten in asyncio.queue / workers

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide please explicit loop

for attempt in range(max_retries + 1):
if attempt:
sleep = min(max_backoff, initial_backoff * 2 ** (attempt - 1))
await asyncio.sleep(sleep)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide please explicit loop

@RainJayTsai
Copy link
Author

Ok, I am refactoring

from aioelasticsearch import Elasticsearch
from aioelasticsearch.helpers import bulk

def gen_data():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about to make it async gen? It Should be really usefull

@janLo
Copy link

janLo commented May 6, 2020

I stumbled upon this because I need bulk in a asyncio project. What is the current status of this PR? Is there a particular reason why it was never merged?

@Ronserruya
Copy link

^^ Bulk is a really critical part of working with ES, any estimate for this?

@CLAassistant

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants